<?php
/**
 * 用户登陆
 */
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {		
	
    //用户登陆页面
    public function index(){
        $this->display();
    }
    //用户登陆验证
    public function login(){
    	session(null);
    	$db = M('member');
    	$username = I('username');
    	$password = I('password','','md5');
    	$user = $db->where(array('username'=>$username,'password'=>$password,))->find();
		if (!$user) {
			$this->error("账号或密码错误");
		}
		if($user['status'] == '0'){
			$this->error("账号被锁定");
		}
		//更新数据信息
		$data =array( 
			'id' => $user['id'],
			'logintime' => time(),
			'loginip' => get_client_ip(),
		);	
		$db->save($data);  
		//把用登陆信息存到SESSION
		session("username",$user['username']);
		session("userid",$user['id']);	
		$this->success("登陆成功",__APP__."/Admin");
    }
}